package com.zhaoqi.hr.dto.request;

import com.zhaoqi.hr.entity.JobPosting;

import javax.validation.constraints.DecimalMin;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.Objects;

/**
 * 岗位发布请求DTO
 */
public class JobPostingRequest {
    
    /**
     * 岗位标题
     */
    @NotBlank(message = "岗位标题不能为空")
    private String title;
    
    /**
     * 岗位描述
     */
    @NotBlank(message = "岗位描述不能为空")
    private String description;
    
    /**
     * 岗位类型
     */
    @NotNull(message = "岗位类型不能为空")
    private JobPosting.JobType jobType;
    
    /**
     * 工作地点
     */
    @NotBlank(message = "工作地点不能为空")
    private String location;
    
    /**
     * 薪资（元/小时或元/天）
     */
    @NotNull(message = "薪资不能为空")
    @DecimalMin(value = "0.01", message = "薪资必须大于0")
    private BigDecimal salary;
    
    /**
     * 薪资类型
     */
    @NotNull(message = "薪资类型不能为空")
    private JobPosting.SalaryType salaryType;
    
    /**
     * 需要人数
     */
    @NotNull(message = "需要人数不能为空")
    @Min(value = 1, message = "需要人数至少为1")
    private Integer requiredCount;
    
    /**
     * 工作开始时间
     */
    @NotNull(message = "工作开始时间不能为空")
    private LocalDateTime startTime;
    
    /**
     * 工作结束时间
     */
    @NotNull(message = "工作结束时间不能为空")
    private LocalDateTime endTime;
    
    /**
     * 技能要求
     */
    private String skillRequirements;
    
    /**
     * 其他要求
     */
    private String otherRequirements;
    
    /**
     * 联系方式
     */
    private String contactInfo;
    
    /**
     * 用工方ID（管理员创建岗位时指定）
     */
    private Long employerId;
    
    /**
     * 分配的劳动者ID（可选）
     */
    private Long assignedWorkerId;

    // Getter and Setter methods
    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public JobPosting.JobType getJobType() {
        return jobType;
    }

    public void setJobType(JobPosting.JobType jobType) {
        this.jobType = jobType;
    }

    public String getLocation() {
        return location;
    }

    public void setLocation(String location) {
        this.location = location;
    }

    public BigDecimal getSalary() {
        return salary;
    }

    public void setSalary(BigDecimal salary) {
        this.salary = salary;
    }

    public JobPosting.SalaryType getSalaryType() {
        return salaryType;
    }

    public void setSalaryType(JobPosting.SalaryType salaryType) {
        this.salaryType = salaryType;
    }

    public Integer getRequiredCount() {
        return requiredCount;
    }

    public void setRequiredCount(Integer requiredCount) {
        this.requiredCount = requiredCount;
    }

    public LocalDateTime getStartTime() {
        return startTime;
    }

    public void setStartTime(LocalDateTime startTime) {
        this.startTime = startTime;
    }

    public LocalDateTime getEndTime() {
        return endTime;
    }

    public void setEndTime(LocalDateTime endTime) {
        this.endTime = endTime;
    }

    public String getSkillRequirements() {
        return skillRequirements;
    }

    public void setSkillRequirements(String skillRequirements) {
        this.skillRequirements = skillRequirements;
    }

    public String getOtherRequirements() {
        return otherRequirements;
    }

    public void setOtherRequirements(String otherRequirements) {
        this.otherRequirements = otherRequirements;
    }

    public String getContactInfo() {
        return contactInfo;
    }

    public void setContactInfo(String contactInfo) {
        this.contactInfo = contactInfo;
    }

    public Long getEmployerId() {
        return employerId;
    }

    public void setEmployerId(Long employerId) {
        this.employerId = employerId;
    }

    public Long getAssignedWorkerId() {
        return assignedWorkerId;
    }

    public void setAssignedWorkerId(Long assignedWorkerId) {
        this.assignedWorkerId = assignedWorkerId;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        JobPostingRequest that = (JobPostingRequest) o;
        return Objects.equals(title, that.title) &&
                Objects.equals(description, that.description) &&
                jobType == that.jobType &&
                Objects.equals(location, that.location) &&
                Objects.equals(salary, that.salary) &&
                salaryType == that.salaryType &&
                Objects.equals(requiredCount, that.requiredCount) &&
                Objects.equals(startTime, that.startTime) &&
                Objects.equals(endTime, that.endTime);
    }

    @Override
    public int hashCode() {
        return Objects.hash(title, description, jobType, location, salary, salaryType, requiredCount, startTime, endTime);
    }

    @Override
    public String toString() {
        return "JobPostingRequest{" +
                "title='" + title + '\'' +
                ", description='" + description + '\'' +
                ", jobType=" + jobType +
                ", location='" + location + '\'' +
                ", salary=" + salary +
                ", salaryType=" + salaryType +
                ", requiredCount=" + requiredCount +
                ", startTime=" + startTime +
                ", endTime=" + endTime +
                ", skillRequirements='" + skillRequirements + '\'' +
                ", otherRequirements='" + otherRequirements + '\'' +
                ", contactInfo='" + contactInfo + '\'' +
                '}';
    }
}
